#ifndef FACE_H
#define FACE_H

class Vertex;
#include "Troll3D_global.h"
#include "GeoTool/vec4.h"

#include <vector>

/*!	@brief The face class is used to represent an object's face. A face is, for now, always a GL_TRIANGLES
 *
 *		Brief Workflow Overview : The face class take 3 vertex pointers. To create a new vector, just give a face references to previously created vertices and use the
 *		static function "New". When a face is created, it will automaticcaly fill an Index Buffer wich will then be sent to the IBO Buffer in order to speed rendering
 */
class TROLL3DSHARED_EXPORT Face
{
    public :

        /************************************************/
        /*				Members 						*/
        /************************************************/

            /************************************************/
            /*				Properties 						*/
            /************************************************/

				int						m_Offset;			/*!< Offset of the Index in the m_Index array. This data is very important for glDrawElements, and is set during
																 vector to ushort conversion	*/	
																 
                std::vector<Vertex *> 	m_Vertices;         /*!< Vertices connected to the current face							*/
                std::vector<int> 		m_Index;            /*!< Index of connected vertices. Could be used for IBO creation	*/

                vec4 					m_Normal;           /*!< Surface's normal												*/

            /************************************************/
            /*				Methods 						*/
            /************************************************/

                void ComputeNormal();

        /************************************************/
        /*				Statics 						*/
        /************************************************/

            /************************************************/
            /*				Properties 						*/
            /************************************************/

                static	std::vector<Face *> 		Faces;      /*!< Store all application's faces			*/

            /************************************************/
            /*				Methods 						*/
            /************************************************/

                /*!	@brief Create a new face, storing references to it's connected vertices,
                 *  and add the newly created face in top of static vector Faces                */
                static 	Face * New(Vertex * a, Vertex * b, Vertex * c);

                /*! @brief The array method will tranform the Faces vector so it can be passed to the IBO
                 *  To do so, we inspect all connected faces, get back theirs index, and put it inside an array */
                static unsigned short * Array();

        /************************************************/
        /*				Constructors					*/
        /************************************************/

            Face(Vertex * a, Vertex * b, Vertex * c);
};
#endif





